<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  

  
  <title>xiaxuchen的博客</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta name="description" content="uniapp学习笔记 app端老是没有代码同步 重启Hbuilder底座即可(不得不吐槽，垃圾)  使用tabbar时导航栏相互重叠   原因:配置了导航栏的背景色透明，然后他就能看到所有的导航栏了。。。 解决办法:设置为不透明的颜色。。。  遇到玄学问题搞了两个小时 问题描述:字体文件加载不出来 过程:不断的重启设备重启IDE修改代码，仍然无济于事 解决的步骤:删除掉一行无关紧要的引入commo">
<meta property="og:type" content="article">
<meta property="og:title" content="xiaxuchen的博客">
<meta property="og:url" content="http://yoursite.com/2020/08/07/%E5%89%8D%E7%AB%AF/%E5%AD%A6%E4%B9%A0UniApp%E9%81%87%E5%88%B0%E7%9A%84%E5%9D%91/index.html">
<meta property="og:site_name" content="xiaxuchen的博客">
<meta property="og:description" content="uniapp学习笔记 app端老是没有代码同步 重启Hbuilder底座即可(不得不吐槽，垃圾)  使用tabbar时导航栏相互重叠   原因:配置了导航栏的背景色透明，然后他就能看到所有的导航栏了。。。 解决办法:设置为不透明的颜色。。。  遇到玄学问题搞了两个小时 问题描述:字体文件加载不出来 过程:不断的重启设备重启IDE修改代码，仍然无济于事 解决的步骤:删除掉一行无关紧要的引入commo">
<meta property="og:locale" content="en_US">
<meta property="og:image" content="c:/Users/xxc、/AppData/Roaming/Typora/typora-user-images/image-20200114220114310.png">
<meta property="article:published_time" content="2020-08-07T15:08:02.803Z">
<meta property="article:modified_time" content="2020-07-19T10:36:53.995Z">
<meta property="article:author" content="xiaxuchen">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="c:/Users/xxc、/AppData/Roaming/Typora/typora-user-images/image-20200114220114310.png">
  
    <link rel="alternate" href="./atom.xml" title="xiaxuchen的博客" type="application/atom+xml">
  
  
    <link rel="icon" href="/favicon.png">
  
  
    <link href="//fonts.googleapis.com/css?family=Source+Code+Pro" rel="stylesheet" type="text/css">
  
  
<link rel="stylesheet" href="./css/style.css">

<meta name="generator" content="Hexo 5.0.0"></head>

<body>
  <div id="container">
    <div id="wrap">
      <header id="header">
  <div id="banner"></div>
  <div id="header-outer" class="outer">
    <div id="header-title" class="inner">
      <h1 id="logo-wrap">
        <a href="./" id="logo">xiaxuchen的博客</a>
      </h1>
      
    </div>
    <div id="header-inner" class="inner">
      <nav id="main-nav">
        <a id="main-nav-toggle" class="nav-icon"></a>
        
          <a class="main-nav-link" href="./">Home</a>
        
          <a class="main-nav-link" href="./archives">Archives</a>
        
      </nav>
      <nav id="sub-nav">
        
          <a id="nav-rss-link" class="nav-icon" href="./atom.xml" title="RSS Feed"></a>
        
        <a id="nav-search-btn" class="nav-icon" title="Search"></a>
      </nav>
      <div id="search-form-wrap">
        <form action="//google.com/search" method="get" accept-charset="UTF-8" class="search-form"><input type="search" name="q" class="search-form-input" placeholder="Search"><button type="submit" class="search-form-submit">&#xF002;</button><input type="hidden" name="sitesearch" value="http://yoursite.com"></form>
      </div>
    </div>
  </div>
</header>
      <div class="outer">
        <section id="main"><article id="post-前端/学习UniApp遇到的坑" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="./2020/08/07/%E5%89%8D%E7%AB%AF/%E5%AD%A6%E4%B9%A0UniApp%E9%81%87%E5%88%B0%E7%9A%84%E5%9D%91/" class="article-date">
  <time datetime="2020-08-07T15:08:02.803Z" itemprop="datePublished">2020-08-07</time>
</a>
    
  </div>
  <div class="article-inner">
    
    
    <div class="article-entry" itemprop="articleBody">
      
        <h2 id="uniapp学习笔记"><a href="#uniapp学习笔记" class="headerlink" title="uniapp学习笔记"></a>uniapp学习笔记</h2><ol>
<li><p>app端老是没有代码同步</p>
<p>重启Hbuilder底座即可(不得不吐槽，垃圾)</p>
</li>
<li><p>使用tabbar时导航栏相互重叠</p>
<img src="C:\Users\xxc、\AppData\Roaming\Typora\typora-user-images\image-20200114220114310.png" alt="image-20200114220114310" style="zoom:25%;" />

<p>原因:配置了导航栏的背景色透明，然后他就能看到所有的导航栏了。。。</p>
<p>解决办法:设置为不透明的颜色。。。</p>
</li>
<li><p>遇到玄学问题搞了两个小时</p>
<p>问题描述:字体文件加载不出来</p>
<p>过程:不断的重启设备重启IDE修改代码，仍然无济于事</p>
<p>解决的步骤:删除掉一行无关紧要的引入common.css的代码，可以运行了，猜测是缓存没有清理或者Hbuilder不能全局保存，在引入样式的地方从始至终没有保存，导致字体图标都没有引入</p>
</li>
<li><p>获取video的上下文无法操控video元素</p>
<p>uni.createVideoContext(id)</p>
<p>原因:id不应该加#</p>
</li>
<li><p>在发出事件时使用<strong>中划线</strong>进行间隔，因为html不区分大小写，有时可能会没有效果</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">&#x2F;&#x2F;若发出的事件为onTabToggle，应写为如下形式</span><br><span class="line">&#x2F;&#x2F; 发出切换事件</span><br><span class="line">this.$emit(&#39;on-tab-toggle&#39;, index)</span><br></pre></td></tr></table></figure>



</li>
</ol>
<ol start="6">
<li><p>要使一些元素在同一行排列即使位置不够也不换行的方法:</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">.scroll-h &#123;</span><br><span class="line">        &#x2F;&#x2F; 设置换行方式，不换行</span><br><span class="line">        white-space: nowrap;</span><br><span class="line">        .tab-item &#123;</span><br><span class="line">        &#x2F;&#x2F;将元素设置为行内块</span><br><span class="line">        display: inline-block;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>



</li>
</ol>
<ol start="7">
<li><p>尽量使用es6的箭头函数，去除this作用域</p>
</li>
<li><p>下拉加载更多，使用Scroller-view的下拉事件即可，然后在底部加一个text显示当前的加载信息(如<strong>加载中…</strong>)</p>
</li>
<li><p>在android中，flex布局居中的absolute元素不在web预览同样的位置，通过css调整（其中calc可以计算upx）</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">&amp;&gt;.btn-play &#123;</span><br><span class="line">                position: absolute;</span><br><span class="line">                left: calc(50% - 50upx);</span><br><span class="line">                top: calc(50% - 50upx);</span><br><span class="line">                color: white;</span><br><span class="line">                font-size: 100upx;</span><br><span class="line">            &#125;</span><br></pre></td></tr></table></figure>
</li>
<li><p>css居中</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line">.nothing &#123;</span><br><span class="line">        display: flex;</span><br><span class="line">        align-items: center;</span><br><span class="line">        justify-content: center;</span><br><span class="line">        position: absolute;</span><br><span class="line">        top: 0;</span><br><span class="line">        bottom: 0;</span><br><span class="line">        left: 0;</span><br><span class="line">        right: 0;</span><br><span class="line">        background: #FFFFFF;</span><br><span class="line">        .img &#123;</span><br><span class="line">            width: 40%;</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br></pre></td></tr></table></figure>
</li>
<li><p>android端不识别rgba格式颜色</p>
</li>
<li><p>autoBackButton无效</p>
</li>
<li><p>去除默认导航栏</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">&#x2F;&#x2F; pages.json 页面的style</span><br><span class="line">&quot;app-plus&quot;:&#123;</span><br><span class="line">                    &quot;titleNView&quot;:false</span><br><span class="line">                &#125;</span><br></pre></td></tr></table></figure>

</li>
</ol>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://yoursite.com/2020/08/07/%E5%89%8D%E7%AB%AF/%E5%AD%A6%E4%B9%A0UniApp%E9%81%87%E5%88%B0%E7%9A%84%E5%9D%91/" data-id="ckdkdagun000evout0wf6ci9r" class="article-share-link">Share</a>
      
      
    </footer>
  </div>
  
    
<nav id="article-nav">
  
    <a href="./2020/08/07/%E5%89%8D%E7%AB%AF/%E5%BE%AE%E4%BF%A1%E5%85%AC%E4%BC%97%E5%8F%B7%E9%A1%B9%E7%9B%AE%E5%89%8D%E7%AB%AF%E8%A1%80%E6%B3%AA%E5%8F%B2/" id="article-nav-newer" class="article-nav-link-wrap">
      <strong class="article-nav-caption">Newer</strong>
      <div class="article-nav-title">
        
          (no title)
        
      </div>
    </a>
  
  
    <a href="./2020/08/07/%E5%89%8D%E7%AB%AF/WebPack%E9%85%8D%E7%BD%AE/" id="article-nav-older" class="article-nav-link-wrap">
      <strong class="article-nav-caption">Older</strong>
      <div class="article-nav-title"></div>
    </a>
  
</nav>

  
</article>

</section>
        
          <aside id="sidebar">
  
    

  
    

  
    
  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Archives</h3>
    <div class="widget">
      <ul class="archive-list"><li class="archive-list-item"><a class="archive-list-link" href="./archives/2020/08/">August 2020</a></li></ul>
    </div>
  </div>


  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Recent Posts</h3>
    <div class="widget">
      <ul>
        
          <li>
            <a href="./2020/08/07/%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84/%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84%E4%B9%8B%E9%93%BE%E8%A1%A8/">(no title)</a>
          </li>
        
          <li>
            <a href="./2020/08/07/%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84/%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84%E4%B9%8B%E6%A0%88%E4%B8%8E%E9%98%9F%E5%88%97/">(no title)</a>
          </li>
        
          <li>
            <a href="./2020/08/07/%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84/%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84%E4%B9%8B%E6%95%B0%E7%BB%84/">(no title)</a>
          </li>
        
          <li>
            <a href="./2020/08/07/%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84/%E6%80%9D%E7%BB%B4%E5%AF%BC%E5%9B%BE/">(no title)</a>
          </li>
        
          <li>
            <a href="./2020/08/07/%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84/SpringBoot%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/">(no title)</a>
          </li>
        
      </ul>
    </div>
  </div>

  
</aside>
        
      </div>
      <footer id="footer">
  
  <div class="outer">
    <div id="footer-info" class="inner">
      &copy; 2020 xiaxuchen<br>
      Powered by <a href="http://hexo.io/" target="_blank">Hexo</a>
    </div>
  </div>
</footer>
    </div>
    <nav id="mobile-nav">
  
    <a href="./" class="mobile-nav-link">Home</a>
  
    <a href="./archives" class="mobile-nav-link">Archives</a>
  
</nav>
    

<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>


  
<link rel="stylesheet" href="./fancybox/jquery.fancybox.css">

  
<script src="./fancybox/jquery.fancybox.pack.js"></script>




<script src="./js/script.js"></script>




  </div>
</body>
</html>